////显示普通价格单弹窗 
	 jQuery('#queryQuote').on("click",function(){
		 jQuery("#QuoteModal").modal('show');
	 });
	 
	 //普通价格单table
	 var quoteData={};
	 var quoteTable;
	 quoteData.key='';
	 quoteData.auditState='通过';
	 jQuery(document).ready(function () {
		 quoteTable = jQuery('#quoteTable').DataTable({
	         "serverSide": true,
	         "ordering": false,
	         "ajax": {
	             "dataType": "json",
	             "type": "get",
	             "cache": false,
	             "url":window.rootPath+ '/ui/bid/getAduitQuote',
	             "data": function (d) {
	                 return $.extend({}, d, quoteData);
	             }
	         },
	         columns: [
	             {
	             	data: null,
	             	defaultContent: ""
	             },
	             {
	                 data: null,
	                 defaultContent: "",
	                 render: function (data, type, full, meta) {
	                 	var id=data.id
	 	            	var operate ='<input type="checkbox" class="checkchild">';
	 	            	return operate;
	                 }
	             },
	             {
	                 data: 'name'
	             },
	             {
	            	 data: 'auditState',
	                 render: function (data, type, full, meta) {
	                  	var dOut;
	                  	 if(data=='审批中'){
	                  		dOut = '<td class="center" ><span class="badge label-pill label-primary">审批中</span></td>';
	                  	}
	                  	else if(data=='驳回'){
	                  		dOut = '<td class="center" ><span class="badge label-pill label-danger">驳回</span></td>';
	                  	}
	                  	else if(data=='通过'){
	                  		dOut = '<td class="center" ><span class="badge label-pill label-success">通过</span></td>';
	                  	}
	                  	else  if(data=='未提交'){
	                  		dOut = '<td class="center" ><span class="badge label-pill label-default">未提交</span></td>';
	                  	}
	                 	else  if(data=='已提交'){
	                  		dOut = '<td class="center" ><span class="badge label-pill label-warning">已提交</span></td>';
	                  	}
	  	            	return dOut;
	                  }
	             },
	             {
	                 data: 'sum'
	             },
	             {
	             	data: 'createTime',
	             		render : function(data,type, full,meta) {
	 						if (data) 
	 						{
	 							return moment(data).format("YYYY-MM-DD");
	 						}
	             	}
	             },
	             {
	             	data: 'memo'
	             }
	             
	             ],
	         "drawCallback": function (oSettings) {
	             var k = 0;
	             var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;
	             for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
	                 $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
	                 k++;
	             }

	         }
	     });
	     
	 });
	 
	//查询按钮
	 jQuery('.searchBtn').on('click',function(){
		      quoteData.key=jQuery("#keyword").val();
		      quoteTable.draw();
	      });
		//撤消查询
	 jQuery('.resetBtn').on('click',function(){
	     jQuery('#keyword').val('');
	     quoteData.key='';
	     quoteTable.draw();
	 });
	 
	 ///引入普通价格单
	 jQuery('#pull-quote').on('click',function(){
		 var selects=getSelect("#quoteTable",1);
	   	   if(selects.length>1){
	   		   $.springLemonDialog({
	   		         content: '只能操作一条记录',// 确认文本
	   		         clickButton: function (sender, modal, index) {// 按钮事件处理
	   		             $(this).closeDialog(modal);
	   		         }
	   		   }); 
	   	   }
	   	   else if(selects.length==0){
	   		   $.springLemonDialog({
	   		         content: '请选择要操作的记录',// 确认文本
	   		         clickButton: function (sender, modal, index) {// 按钮事件处理
	   		             $(this).closeDialog(modal);
	   		         }
	   		   }); 
	   	   }else if(selects.length==1){
	   		    jQuery("#quoteId").val(selects[0].id);
		   		jQuery("#quoteName").val(selects[0].name);
		   		jQuery("#quoteMemo").val(selects[0].memo);
		   		jQuery("#costSum").val(selects[0].costSum);
		   		jQuery("#sum").val(selects[0].sum);
		   		jQuery("#ratio").val(selects[0].ratio);
		   		jQuery("#discount").val(selects[0].discount);
		   		jQuery("#assumeSum").val(selects[0].assumeSum);
		   		jQuery("#quoteExplain").val(selects[0].quoteExplain);
		   		var quoteId=selects[0].id;
		   		mainDeviceData.quoteId=quoteId;
		   		mainDeviceTable.draw();
		   		serverData1.quoteId=quoteId;
		   		serverTable1.draw()
		   		////显示报价单的附件数量
			   	   var numId='quoteANum';
			       showANum(quoteId,'普通价格单附件',numId);
		   		jQuery("#QuoteModal").modal('hide'); 		
	   	   }  
	 })
	 // 新增投标，引入价格单的下载附件
	 
	 jQuery(".downquote").on('click', function() {
		var quoteId = jQuery("#quoteId").val();
			filedown(quoteId, '普通价格单附件',0);
	 });
	 
	 /////点击编辑普通价格单tab
	 jQuery("#t2").on('click', function() {
           var bidId= jQuery("#bidId").val();
           var url=window.rootPath+"/ui/bid/getBid"+"?bidId="+bidId;
           jQuery.ajax({
				type : 'get',
				url : encodeURI(url),
				dataType : 'json',
				contentType : 'application/json;charset=utf-8',
				success : function(data) {
					if(data==null){
						var quoteId=data.quote.id
						jQuery("#quoteId").val(quoteId);
				   		jQuery("#quoteName").val(data.quote.name);
				   		var quoteMemo=data.quote.memo;
				   		jQuery("#quoteMemo").val(quoteMemo);
				   		jQuery("#costSum").val(data.quote.costSum);
				   		jQuery("#assumeSum").val(data.quote.assumeSum);
				   		jQuery("#sum").val(data.quote.sum);
				   		jQuery("#ratio").val(data.quote.ratio);
				   		jQuery("#discount").val(data.quote.discount);
				   		jQuery("#quoteExplain").val(data.quote.quoteExplain);
				   		
				   		mainDeviceData.quoteId=quoteId;
				   		mainDeviceTable.draw();
				   		serverData1.quoteId=quoteId;
				   		serverTable1.draw()
				   		////显示报价单的附件数量
				   	   var numId='quoteANum';
				   		if(quoteId!=undefined){
				   			showANum(quoteId,'普通价格单附件',numId);
				   		}
					}
			   		
				}
			});
           
			
		 });
	 ////主机设备
	 var mainDeviceData = {};
		var mainDeviceTable;
		jQuery(document).ready(function() {
			mainDeviceTable = jQuery('#mainDeviceTable').DataTable({
						"serverSide" : true,
						"ordering" : false,
						"ajax" : {
							"dataType" : "json",
							"type" : "get",
							"cache" : false,
							"url" : window.rootPath+ '/ui/quote/getDevicepage',
							"data" : function(d) {
								return $.extend({}, d,mainDeviceData);
									}
								},
								columns : [ {
									data : null,
									defaultContent : ""
								}, 
								{
									data : 'productName'
								}, 
								{
									data : 'productType'
								}, 
								{
									data : 'productModel'
								},
								{
									data : null,
									render : function(data,type, full, meta) {
										var dOut;
										if (data.isInventory == "1") {
										 dOut = '<td class="center" ><span class="badge label-pill label-success">已降库</span></td>';
												} 
										else {
										 dOut = '<td class="center" ><span class="badge label-pill label-danger">未降库</span></td>';
												}
										return dOut;
											}
								},
								{
									data : 'number'
								},
								{
									data:'unit'
								}, 
								{
									data : 'costPrice'
								},
								{
									data : 'unitPrice'
								}, {
									data : 'power'
								}, {
									data : 'flowMaterial'
								}, {
									data : 'transMedia'
								}, {
									data : 'viscosity'
								}, {
									data : 'flux'
								}, {
									data : 'pumpLift'
								}, {
									data : 'temperature'
								}, {
									data : 'proportion'
								}, {
									data : 'inPressure'
								}, {
									data : 'effectiveNPSHA'
								}, {
									data : 'mustMPSHA'
								} ],
							"drawCallback" : function(oSettings) {
									var k = 0;
									var total = oSettings.aiDisplay.length+ oSettings._iDisplayStart;
									for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
										$('td:eq(0)',oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
												k++;
											}

										}
									});
				});
	////其他设备	
		 var serverData1 = {};
		 var serverTable1;
			jQuery(document).ready(function() {
				serverTable1 = jQuery('#otherTable').DataTable({
						"serverSide" : true,
						"ordering" : false,
						"ajax" : {
						"dataType" : "json",
						"type" : "get",
						"cache" : false,
						"url" : window.rootPath+'/ui/quote/getOtherpage',
						"data" : function(d) {
								return $.extend({}, d,serverData1);
												}
								},
								columns : [ {
									data : null,
									defaultContent : ""
								}, {
									data : 'deviceName'
								}, {
									data : 'type'
								}, 
								{
									data : 'material'
								},
								{
									data : 'unit'
								}, {
									data : 'amount'
								},
								{
									data : 'costPrice'
								},
								{
									data : 'price'
								} ],
						"drawCallback" : function(oSettings) {
									  var k = 0;
									  var total = oSettings.aiDisplay.length+ oSettings._iDisplayStart;
									for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
									    $('td:eq(0)',oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
												k++;
													}
												}
											});

						});
	
